#{extends 'main.html' /} #{set title:'Home' /}
<!-- @author Heidi eltoukhy
this page retrieves a list with all the requests received by the creator from others to join
his communityList-->
<body style="background-color: White;">
<body>
	<h2
		style="background-color: #FF6600; font-family: Arial; font-size: 20px">
		<p style="color: white;">
			<i>Your CommunityLists Request:</i>
		</p>
	</h2>

	#{ifnot creatorCommRequests}
	<p
		style="background-color: #778899; width: 300px; text-align: top; font-size: 20px;">
		No One Asked To Join Any Communitylists !!</p>
	#{/ifnot} #{if !creatorCommRequests.empty}
	<table width="300" id="dataTable" background="lightblue" ; border="2"
		; BORDERCOLOR=#FF6600>
		<tr>
			<th
				style="background-color: #778899; font-family: Arial; font-size: 20px"><p
					style="color: white;">Request</p></th>
			<th
				style="background-color: #778899; font-family: Arial; font-size: 20px"><p
					style="color: white;">Action</p></th>

			<th
				style="background-color: #778899; font-family: Arial; font-size: 20px"><p
					style="color: white;">Action</p>
			</th> #{list items:creatorCommRequests,as:'commListRequests'}
		</tr>

		<td>
			<ul>
				<li><h4>
						Request From:
						${models.RegisteredUser.findById(commListRequests.senderId).name}
						<br>
					</h4>
				</li>
			</ul>
			<ul>
				<li><h4>To Join The Community List:
						${models.CommunityList.findById(commListRequests.commListId).name}</h4>
				</li>
			</ul>
		</td>
		<td>
			<!-- Begin @author Ayatullah Marawan
	There are two buttons next to each request, "accept" for accepting the request of member
	and one "reject" for rejecting the member's request--> <script
				type="text/javascript">
			function confirmation() {
				var answer = confirm("Are you sure you want to accept this Request?")
				if (answer) {
					alert("you have accepted this request successfully")
					return true
				} else {
					return false
				}
			}
		</script>
			<form action="@{CommunityLists.CreatorAcceptJoiners()}" method="GET">
				<div id="${commListRequests.id}">
					<button name="accept" type="submit" value="${commListRequests.id}"
						onClick="return confirmation()">Accept</button>
				</div>
			</form> <!-- End @author Ayatullah Marawan--></td>
		<td>
			<div id="${commListRequests.id}">
				<br>
				<script type="text/javascript">
					function confirmationTwo() {
						var answer = confirm("Are you sure you want to reject this Request?")
						if (answer) {
							alert("you have rejected this request successfully")
							return true
						} else {
							return false
						}
					}
				</script>
				<form action="@{CommunityLists.CreatorRejectJoiners()}" method="GET">
					<div id="${commListRequests.id}">
						<button name="reject" type="submit" value="${commListRequests.id}"
							onClick="return confirmationTwo()">Reject</button>
				</form>
			</div></td> #{/list}
	</table>
	#{/if}
	<br>
	<form>
		<li><a href="@{Application.viewProfile()}">Back to Profile
				Page</a></li>
	</form>
	<br>


</body>